package com.mhwx.mhlive.ui.widget;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Display;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.mhwx.mhlive.R;


/**
 * 类功能描述
 *点击头像弹出
 * @author Guol
 * @version 1.0
 * @copyright 北京明华维新信息技术有限公司
 * @time 2017/5/3
 */
public class DialogHear  extends Dialog implements View.OnClickListener{

   private Context context;
    private CallBackListener listener;

    public DialogHear(Context context) {
        super(context, R.style.Dialog);
        this.context=context;

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dailog_hear);
        intView();
    }

    private void intView(){
        Window dialogWindow = getWindow();
        WindowManager manager = ((Activity) context).getWindowManager();
        WindowManager.LayoutParams params = dialogWindow.getAttributes(); // 获取对话框当前的参数值
        dialogWindow.setGravity(Gravity.CENTER);//设置对话框位置
        Display d = manager.getDefaultDisplay(); // 获取屏幕宽、高度
        params.width = (int) (d.getWidth() * 0.8); // 宽度设置为屏幕的0.65，根据实际情况调整
        dialogWindow.setAttributes(params);

    }


    @Override
    public void onClick(View view) {
        switch (view.getId()){
             case  R.id.tv_report:

            break;
            case  R.id.img_close:
                if (listener!=null) {
                    listener.cancleListener();
                }
                break;
        }
    }


    public interface CallBackListener{
        /**
         * 取消
         */
        void cancleListener();
        /**
         * 确定
         *  获取EditText 输入的内容
         */
        void confirmListener(String text);
    }
}
